package itheima.zuoye.Test7;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class test {
    public static void main(String[] args) {
        TreeMap<Laomo,String> map = new TreeMap<>();
        map.put(new Laomo("张三", 18), "北京");
        map.put(new Laomo("李四", 20), "上海");
        map.put(new Laomo("王五", 35), "天津");
        map.put(new Laomo("赵六", 21), "北京");
        map.put(new Laomo("田七", 19), "上海");


       //需求一：删除张三的信息
        map.remove(new Laomo("张三", 18));
        //需求二：修改李四的家庭住址为郑州
        map.put(new Laomo("李四", 20), "郑州");


        for (Laomo key : map.keySet()) {
            System.out.println(key + "--->" + map.get(key));
        }

        System.out.println("===================");

        map.entrySet().forEach(entry-> System.out.println(entry.getKey()+"--->"+entry.getValue()));




        System.out.println("===================");

        Set<Map.Entry<Laomo, String>> entries = map.entrySet();
        for (Map.Entry<Laomo, String> entry : entries) {
            System.out.println(entry.getKey()+"--->"+entry.getValue());
        }



    }
}
